﻿Imports Microsoft.VisualBasic

Namespace ClubStarterKit.Web.Controls

    Public Class RolloverButton
        Inherits Button

        Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)
            MyBase.AddAttributesToRender(writer)
            writer.AddAttribute("onmouseover", "this.className='button';")
            writer.AddAttribute("onmouseout", "this.className='button';")
            writer.AddAttribute("class", "button")
        End Sub
    End Class

    Public Class RolloverLink
        Inherits Button

        Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)
            MyBase.AddAttributesToRender(writer)
            writer.AddAttribute("onmouseover", "this.className='button'")
            writer.AddAttribute("onmouseout", "this.className='button'")
            writer.AddAttribute("class", "button")

            Dim navurl As String = NavigateURL
            If (MyBase.OnClientClick = "" And navurl <> "") Then
                writer.AddAttribute("onclick", "window.navigate('" & navurl & "');")
            End If

        End Sub

        Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
            MyBase.OnClick(e)
            Dim navurl As String = NavigateURL
            If navurl <> "" Then
                Page.Response.Redirect(NavigateURL)
            End If
        End Sub

        Public Property NavigateURL() As String
            Get
                Dim u As Object = ViewState("NavigateURL")
                If u Is Nothing Then
                    Return ""
                Else
                    Return CStr(u)
                End If
            End Get
            Set(ByVal value As String)
                ViewState("NavigateURL") = value
            End Set
        End Property
    End Class

End Namespace
